<include file="Public/head" />
<link type="text/css" rel="stylesheet" href="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.css" />
<script src="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.js" type="text/javascript"></script>
<style type="text/css">
    .employee .employee_left,.employee_right{width: 50%;float:left;}
    .select2-container .select2-choice > .select2-chosen{text-align: center;}
</style>
</head>
<body>
<include file="Public/common_header" />
<div class="mian">
    <include file="Public/sidebar" menu='xtgl.jtj4sdgl' />
    <form action="/fours/fm_eidt/fid/{$info.fid}" method="post" id="fm" >
        <div class="mianR">
            <h3 class="yonghu">4s店管理-修改</h3>
            <div class="shangFrom shangFrom1 clearfix">
                <div class="chang-ci">
                </div>
            </div>
            <div class="employee">
                <div class="employee_left">
                    <ul class="clearfix">
                        <li>
                            <span>*4S店名称：</span>
                            <input type="text" name="f_name" value="{$info.f_name}" />
                        </li>
                        <li>
                            <span>4S店地址：</span>
                            <input type="text" name="addr" value="{$info.addr}" />
                        </li>
                        <li>
                            <span>联系人：</span>
                            <input type="text" name="contact"  value="{$info.contact}" />
                        </li>
                        <li>
                            <span>联系电话：</span>
                            <input type="text" name="phone"  value="{$info.phone}" />
                        </li>
                        <li>
                            <span>请选择分公司：</span>
                            <select name="branch_company" id="branch_company" onchange='get_developer()' >
                                <option value="0">请选择分公司</option>
                                <foreach name="bc_list" item="val" key="key" >
                                    <option value="{$key}"
                                    <?php if ($key == $info['developer_bc_id']): ?>
                                    selected = "selected"
                                    <?php endif ?>
                                    >{$val}</option>
                                </foreach>
                            </select>
                        </li>
                        <li>
                            <span>4S开发人：</span>
                            <select name="developer" id="developer"  value="{$info.developer}"></select>
                        </li>
                        <li>
                            <span>*所属城市：</span>
                            <select name="bc_city" id="bc_city" >
                                <foreach name="bc_city" item="v" key="k" >
                                    <option value="{$k}"
                                    <?php if ($k == $info['city']): ?>
                                    selected = "selected"
                                    <?php endif ?>
                                    >{$v}</option>
                                </foreach>
                            </select>
                        </li>
                        <li>
                            <span>所属集团：</span>
                            <select name="b_id" id="bid">
                                <option value="">请选择所属集团</option>
                                <volist name='allbloc' id='bloc'>
                                    <option value="{$bloc.bid}"
                                    <?php if ($bloc['bid'] == $info['bid']): ?>
                                    selected = "selected"
                                    <?php endif ?>
                                    >{$bloc.b_name}</option>
                                </volist>
                            </select>
                        </li>
                    </ul>
                </div>
                <div class="employee_right">
                    <ul class="clearfix">
                        <?php if ($eidt_auth): ?>
                        <if condition="$fours_bank_account_count gt 1">
                            <volist name="fours_bank_account_list" id="fbal" key="k">
                                <li>
                                    <span>开户银行{$k}：</span>
                                    <input type="text" name="bank_name_{$fbal.id}"  value="{$fbal.bank_name}" />
                                </li>
                                <li>
                                    <span>银行账号{$k}：</span>
                                    <input type="text" name="card_no_{$fbal.id}"  value="{$fbal.card_no}" />
                                </li>
                                <li>
                                    <span>账户名{$k}：</span>
                                    <input type="text" name="account_name_{$fbal.id}"  value="{$fbal.account_name}" />
                                </li>
                            </volist>
                            <else />
                            <volist name="fours_bank_account_list" id="fbal" key="k">
                                <li>
                                    <span>开户银行1：</span>
                                    <input type="hidden" name="account_id_{$fbal.fid}"  value="{$fbal.id}" />
                                    <input type="text" name="bank_name_{$fbal.id}"  value="{$fbal.bank_name}" />
                                </li>
                                <li>
                                    <span>银行账号1：</span>
                                    <input type="text" name="card_no_{$fbal.id}"  value="{$fbal.card_no}" />
                                </li>
                                <li>
                                    <span>账户名1：</span>
                                    <input type="text" name="account_name_{$fbal.id}"  value="{$fbal.account_name}" />
                                </li>
                            </volist>
                            <li>
                                <span>开户银行2：</span>
                                <input type="text" name="bank_name"  value="" />
                            </li>
                            <li>
                                <span>银行账号2：</span>
                                <input type="text" name="card_no"  value="" />
                            </li>
                            <li>
                                <span>账户名2：</span>
                                <input type="text" name="account_name"  value="" />
                            </li>
                        </if>
                        <?php else : ?>
                        <volist name="fours_bank_account_list" id="fbal" key="k">
                            <li>
                                <span>开户银行{$k}：</span>
                                <span style="width:200px;text-align: left;">{$fbal.bank_name}</span>
                            </li>
                            <li>
                                <span>银行账号{$k}：</span>
                                <span style="width:200px;text-align: left">{$fbal.card_no}</span>
                            </li>
                            <li>
                                <span>账户名{$k}：</span>
                                <span style="width:200px;text-align: left">{$fbal.account_name}</span>
                            </li>
                        </volist>
                        <?php endif ?>
                    </ul>
                    <input type="hidden" name="channel_id"  value="{$info.channel_id}" />
                </div>
                <div class="clear"></div>
            </div>
            <div class="yongBtn">
                <input type="button" onclick="return Submit();" value="确定" class="queding" />
                <input name="重置" type="reset" class="quxiao" onclick="history.go(-1);" value="取消" />
            </div>
        </div>
    </form>
</div>
<script>
    $("#bid").select2();
    $("#bc_city").select2();
    $("#branch_company").select2();
    function get_developer(){
        var branch_company_id = $('#branch_company option:selected').val();
        $.post("/Fours/get_shop_developer", {"branch_company_id": branch_company_id}, function (data) {
            var optstr = '';
            if (data.code == 200) {
                $.each(data.data, function (k, val) {
                    if (val.emp_id == {$info['developer']}) {
                        optstr += "<option value='" + val.emp_id + "' selected='selected' >" + val.real_name + "</option>"
                    }else{
                        optstr += "<option value='" + val.emp_id + "'>" + val.real_name + "</option>"
                    }
                })
            }
            optstr = "<option value='0'>请选择开发人</option>" + optstr;
            $("#developer").html(optstr).select2();
            $("#developer").select2();
        }, "json");
    }
    get_developer();
  
    function Submit(){
        post_submit_json('fm',function(data){
            if(data.code != 200){
                shibai_alert(data.msg);
                return false;
            }
            //成功回调
            btn_alert("修改成功",1000,function(){
                location.href = document.referrer;
            });
        })    
        return false;
    }

</script>
<include file="Public/foot" />